import axios, { type AxiosPromise } from "axios";

export const service = axios.create({
    baseURL: "",
    timeout: 10000,
    headers: {
        'Content-Type': 'application/json;charset=utf-8', 'X-Requested-With': 'XMLHttpRequest'
    }
});

export function login(): AxiosPromise<any> {
    return service({
        url: "/api/login",
        method: "post",
    });
}
//登录接口
export function loginApi(data: UserLogin): AxiosPromise<any> {
    return service({
        url: "/api/user/login",
        method: "post",
        data
    });
}

//修改密码接口
export function changePasswordApi(data: UserchangePassword): AxiosPromise<any> {
    return service({
        url: "/api/user/changePassword",
        method: "post",
        data
    });
}
//获取消息列表
export function getMessageListApi(): AxiosPromise<any> {
    return service({
        url: "/api/user/getMessage",
        method: "get",
    })
}
export function changeuserApi(data: any): AxiosPromise<any> {
    return service({
        url: "/api/user/changeuser",
        method: "post",
        data
    })
}
//获取用户列表
export function getUserListApi(): AxiosPromise<any> {
    return service({
        url: "/api/user/getList",
        method: "get",
    })
}

//删除用户
export function deleteuserApi(data: UserDelete): AxiosPromise<any> {
    return service({
        url: "/api/user/delete",
        method: "post",
        data
    })
}

//修改用户
export function updateuserApi(data: User): AxiosPromise<any> {
    return service({
        url: "/api/user/update",
        method: "post",
        data
    })
}

//添加用户
export function adduserApi(data: User): AxiosPromise<any> {
    return service({
        url: "/api/user/add",
        method: "post",
        data
    })
}
//更新用户数据 
export function searchuserApi(data: any): AxiosPromise<any> {
    return service({
        url: "/api/user/search",
        method: "post",
        data
    })
}
//获取商品列表
export function getGoodsListApi(): AxiosPromise<any> {
    return service({
        url: "/api/goods/getlist",
        method: "get",
    })
}

//删除商品
export function deleteGoodsApi(data: any): AxiosPromise<any> {
    return service({
        url: "/api/goods/delete",
        method: "post",
        data
    })
}
//修改商品
export function updateGoodsApi(data: Goods): AxiosPromise<any> {
    return service({
        url: "/api/goods/edit",
        method: "post",
        data
    })
}
//添加商品
export function addGoodsApi(data: Goods): AxiosPromise<any> {
    return service({
        url: "/api/goods/add",
        method: "post",
        data
    })
}
//搜索商品
export function searchGoodsApi(data: any): AxiosPromise<any> {
    return service({
        url: "/api/goods/search",
        method: "post",
        data
    })
}
//获取借阅列表
export function getBorrowListApi(): AxiosPromise<any> {
    return service({
        url: "/api/borrow/getlist",
        method: "get",
    })
}

//删除借阅
export function deleteBorrowApi(data: Borrowdelete): AxiosPromise<any> {
    return service({
        url: "/api/borrow/delete",
        method: "post",
        data
    })
}
//添加借阅
export function addBorrowApi(data: updateBorrow): AxiosPromise<any> {
    return service({
        url: "/api/borrow/add",
        method: "post",
        data
    })
}
//修改借阅
export function updateBorrowApi(data: updateBorrow): AxiosPromise<any> {
    return service({
        url: "/api/borrow/update",
        method: "post",
        data
    })
}
export function searchborrowkApi(data: any): AxiosPromise<any> {
    return service({
        url: "/api/borrow/search",
        method: "post",
        data
    })
}

export function sbmitfeedbackApi(data: any): AxiosPromise<any> {
    return service({
        url: "/api/user/feedback",
        method: "post",
        data
    })
}
export function getshoppingApi():AxiosPromise<any>{
    return service({
        url:"/api/goods/shopping",
        method:"get"
    })
}